﻿using HttpCode.Core;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Zj.HttpCodeDemo.ConsoleView.Sys
{
    /// <summary>
    /// http helper
    /// </summary>
    public class HttpHelper
    {
        /// <summary>
        /// get html string from url async
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static async Task<string> DownloadHtmlAsync(string url)
        {
            HttpHelpers helpers = new HttpHelpers();

            HttpItems items = new HttpItems();
            items.Url = url;
            items.Method = "POST";

            HttpResults hr = await helpers.GetHtmlAsync(items);
            return hr.StatusCode == System.Net.HttpStatusCode.OK ? hr.Html : "";
        }
    }
}
